{extend name="public:layout" /}
{block name="title"}线索跟进{/block}
{block name="head"}
<style>
    body{background:#e8e8e8;}
</style>
{/block}
{block name="body"}
<div class="leads-info-box" id="leadsInfo">

</div>
<div class="app-form2">
    <form class="am-form app-form-line" action="{:url('home/Leads/addRecord')}" method="post">
        <fieldset>
            <input type="hidden" class="input-text" datatype="*" name="leads_id" value="{$Request.param.leads_id}">
            <div class="am-form-group">
                <label for="record_title" class="tit">跟进标题</label>
                <input type="text" class="input-text" id="record_title" name="record_title" datatype="*" nullmsg="请填写跟进主题" placeholder="请填写跟进主题">
            </div>
            <div class="am-form-group">
                <label for="record_remark" class="tit">跟进内容</label>
                <textarea class="textarea-text" name="record_remark" datatype="*" nullmsg="请填写跟进内容" rows="5" id="record_remark" placeholder="请输入备注信息"></textarea>
            </div>
            <div class="submit-box f-hidden">
                <button type="submit" onclick="ajaxSubForm(this)"  class="am-btn am-btn-block am-btn-primary btnSub">线索跟进</button>
            </div>
        </fieldset>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/html" id="leadsInfo-tpl">
    <div class="info-box">
        <div class="thumb">
            <img src="/public/home/plugins/crm_app/img/head_img/head_img_01.png" alt="">
        </div>
        <h2 class="name">{{ data.name }}<span class="sex">{{ data.sex }}</span></h2>
        <span class="mobile">联系电话：{{ data.mobile }}</span>
        <p class="info">录入时间：{{ data.create_time }}
            {{ if data.record_count!='' }}跟进：{{ data.record_count }}次<br>最近跟进：{{ data.last_time }} 跟进人:{{ data.last_name }}{{ /if }}</p>
    </div>
</script>
<script>
    $(function () {
        var leads_id="{$Request.param.leads_id}";
        if(leads_id!=''){
            $.post("{:url('home/Leads/getOneInfo')}",{leads_id:leads_id},function (res) {
                if(res.status==2){
                    layerMsg('线索信息不存在',function () {
                        location.href="{:url('home/Index/index',['folder'=>'leads','file'=>'list'])}";
                    })
                }else{
                    console.log(res);
                    var html=template('leadsInfo-tpl',{data:res.data});
                    $('#leadsInfo').empty().html(html);
                }
            })
        }else{
            layerMsg('线索信息不存在',function () {
                location.href="{:url('home/Index/index',['folder'=>'leads','file'=>'list'])}";
            })
        }
        dd.ready(function () {
            dd.biz.navigation.setMenu({
                backgroundColor : "#ADD8E6",
                textColor : "#ADD8E611",
                items : [
                    {
                        "id":"1",//字符串
                        "iconId":"add",//字符串，图标命名
                        "text":"保存",
                        "url": "http://static.dingtalk.com/media/lALPBbCc1S7GyFVAQA_64_64.png"
                    },
                    {
                        "id":"2",
                        "iconId":"calendar",
                        "text":"线索列表"
                    },
                    {
                        "id":"3",
                        "iconId":"calendar",
                        "text":"主页"
                    },
                    {
                        "id":"4",
                        "iconId":"time",
                        "text":"刷新",
                    },
                ],
                onSuccess: function(data) {
                    if(data.id==1){
                        /*保存跟进*/
                        $('.btnSub').click();
                    }else if(data.id==2){
                        /*线索列表*/
                        location.href="{:url('home/Index/index',['folder'=>'leads','file'=>'list'])}"+'&leads_status=1';
                    }else if(data.id==3){
                        /*返回主页*/
                        location.href="{:url('home/Index/index',['folder'=>'index','file'=>'index'])}";
                    }
                    else if(data.id==4){
                        /*刷新页面*/
                        location.reload();
                    };
                },
                onFail: function(err) {
                }
            });
        })
    })

</script>
{/block}